<!--Billboard-->
<div id="container_billboard_parts">
    <div id="part_search_holder">
        <div id="part_search">

            <form method="GET" action="">
                <input type="hidden" name="p" value="index_parts" />
                <!-- SEARCH MENU -->
                <h2>Search For Parts</h2>
                <div class="select_holder_colum">
                   
                    <div class="select_holder">
                        <h3>Make</h3>
                        <div class="select_style_main_page">
                            <select name="make" id="make" onchange="get_model(this.value)">
                                <option value="">-- select --</option>
                                <?php
                                foreach ($data->lists['makes'] as $v) {
                                    if($v == $data->make) {
                                        echo "<option value='".$v."' selected>${v}</option>";
                                    } else {
                                        echo "<option value='".$v."'>${v}</option>";
                                    }
                                }
                                ?>
                            </select>
                        </div>
                    </div>
                    <div class="select_holder">
                        <h3>Min Price</h3>
                        <div class="select_style_main_page">
                            <select name="min_price" id="min_price">
                                <option value="">-- select --</option>
                                <option value="50" <?php echo ($data->min_price == '50' ? 'selected="selected"' : '');?>>₦ 50</option>
                                <option value="100" <?php echo ($data->min_price == '100' ? 'selected="selected"' : '');?>>₦ 100</option>
                                <option value="500" <?php echo ($data->min_price == '500' ? 'selected="selected"' : '');?>>₦ 500</option>
                                <option value="1000" <?php echo ($data->min_price == '1000' ? 'selected="selected"' : '');?>>₦ 1000</option>
                                <option value="5000" <?php echo ($data->min_price == '5000' ? 'selected="selected"' : '');?>>₦ 5000</option>
                            </select>
                        </div>
                    </div>
                     <div class="select_holder">
                        <h3>Year (or newer)</h3>
                        <div class="select_style_main_page">
                            <select name="year" id="year">
                                <option value="">-- select --</option>
                                <option value="1990" <?php echo ($data->year == '1990' ? 'selected="selected"' : '');?>>1990</option>
                                <option value="1995" <?php echo ($data->year == '1995' ? 'selected="selected"' : '');?>>1995</option>
                                <option value="1997" <?php echo ($data->year == '1997' ? 'selected="selected"' : '');?>>1997</option>
                                <option value="1999" <?php echo ($data->year == '1999' ? 'selected="selected"' : '');?>>1999</option>
                                <option value="2001" <?php echo ($data->year == '2001' ? 'selected="selected"' : '');?>>2001</option>
                                <option value="2003" <?php echo ($data->year == '2003' ? 'selected="selected"' : '');?>>2003</option>
                                <option value="2005" <?php echo ($data->year == '2005' ? 'selected="selected"' : '');?>>2005</option>
                                <option value="2007" <?php echo ($data->year == '2007' ? 'selected="selected"' : '');?>>2007</option>
                                <option value="2009" <?php echo ($data->year == '2009' ? 'selected="selected"' : '');?>>2009</option>
                                <option value="2011" <?php echo ($data->year == '2011' ? 'selected="selected"' : '');?>>2011</option>
                                <option value="2013" <?php echo ($data->year == '2013' ? 'selected="selected"' : '');?>>2013</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="select_holder_colum">
                    <div class="select_holder">
                        <h3>Model</h3>
                        <div class="select_style_main_page">
                            <select name="model" id="model"> <!-- populates via AJAX -->
                                <option value="">-- select --</option>
                            </select>
                        </div>
                    </div>
                    <div class="select_holder">
                        <h3>Max Price</h3>
                        <div class="select_style_main_page">
                            <select name="max_price" id="max_price">
                                <option value="99999999">-- select --</option>
                                <option value="100" <?php echo ($data->max_price == '100' ? 'selected="selected"' : '');?>>₦ 100</option>
                                <option value="500" <?php echo ($data->max_price == '500' ? 'selected="selected"' : '');?>>₦ 500</option>
                                <option value="1000" <?php echo ($data->max_price == '1000' ? 'selected="selected"' : '');?>>₦ 1 000</option>
                                <option value="5000" <?php echo ($data->max_price == '5000' ? 'selected="selected"' : '');?>>₦ 5 000</option>
                                <option value="15000" <?php echo ($data->max_price == '15000' ? 'selected="selected"' : '');?>>₦ 15 000</option>
                            </select>
                        </div>
                    </div>
                    
                    
                </div>
                <div class="input_holder_center_parts" id="index_parts_fixing_search">
                    <h3>Keyword</h3>
                    <input type="text" class="fix_search_index_parts" name="keyword" id="keyword" value="<?php echo ($data->keyword ? $data->keyword : '');?>" />
                </div>
                <div class="seach_button_main_page_holder">
                    <input type="image" src="img/search.png" value="Search" name="submit" />
                </div>
            </form>
        </div>
        <div id="ads">
            <div id="ads_holder">
                <div id="create_ad">
                    <a href="?p=adv_add_parts">Create Stock</a>
                </div>
                <div id="manage_ad">
                    <a href="?p=adv_manage">Manage Stocks</a>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- WEB CONTENT -->
<div id="container_content">
<div id="recently_added_holder">
    <h2>Recently Added</h2>
    <div id="recently_added">
        <ul>
            <li>
                <div class="recently_added_holder1">
                    <a href=""><div class="image_fix_width1"><img src="<?php echo ($data->recently_added[0]['picture1'] ? $data->recently_added[0]['picture1'] : 'img/generic_car_part_placeholder.jpg');?>" alt=""></div>
                    <h3>
                        <?php
                        if(!empty($data->recently_added[0]['make'])) {
                            echo 'Car part for '.$data->recently_added[0]['make'].' '.$data->recently_added[0]['model'];
                        } else {
                            echo 'Car Part Ad #'.$data->recently_added[0]['adv_id'];
                        }
                        ?>
                    </h3>
                    </a>
                    <div class="price">
                        <p>
                            <?php echo ($_SESSION['is_logged'] ? $_SESSION['user_data']['currency'].number_format($data->recently_added[0]["price"] *
                                $_SESSION['user_data']['currency_rate'], 0, ".", " ") : '₦ '.number_format($data->recently_added[0]["price"], 0, ".", " "));
                            ?>
                        </p>
                    </div>
                    <div class="car_details_button">
                        <a href="<?php echo ($data->recently_added[0]['price'] ? '?p=adv_view&type=part&adv_id='.$data->recently_added[0]['adv_id'] : '#');?>">Details</a>
                    </div>
                </div>
            </li>
            <li>
                <div class="recently_added_holder1">
                    <a href=""><div class="image_fix_width1"><img src="<?php echo ($data->recently_added[1]['picture1'] ? $data->recently_added[1]['picture1'] : 'img/generic_car_part_placeholder.jpg');?>" alt=""></div>
                    <h3>
                        <?php
                        if(!empty($data->recently_added[1]['make'])) {
                            echo 'Car part for '.$data->recently_added[1]['make'].' '.$data->recently_added[1]['model'];
                        } else {
                            echo 'Car Part Ad #'.$data->recently_added[1]['adv_id'];
                        }
                        ?>
                    </h3>
                    </a>
                    <div class="price">
                        <p>
                            <?php echo ($_SESSION['is_logged'] ? $_SESSION['user_data']['currency'].number_format($data->recently_added[1]["price"] *
                                $_SESSION['user_data']['currency_rate'], 0, ".", " ") : '₦ '.number_format($data->recently_added[1]["price"], 0, ".", " "));
                            ?>
                        </p>
                    </div>
                    <div class="car_details_button">
                        <a href="<?php echo ($data->recently_added[1]['price'] ? '?p=adv_view&type=part&adv_id='.$data->recently_added[1]['adv_id'] : '#');?>">Details</a>
                    </div>
                </div>
            </li>
            <li>
                <div class="recently_added_holder1">
                   <a href=""> <div class="image_fix_width1"><img src="<?php echo ($data->recently_added[2]['picture1'] ? $data->recently_added[2]['picture1'] : 'img/generic_car_part_placeholder.jpg');?>" alt=""></div>
                    <h3>
                        <?php
                        if(!empty($data->recently_added[2]['make'])) {
                            echo 'Car part for '.$data->recently_added[2]['make'].' '.$data->recently_added[2]['model'];
                        } else {
                            echo 'Car Part Ad #'.$data->recently_added[2]['adv_id'];
                        }
                        ?>
                    </h3>
                    </a>
                    <div class="price">
                        <p>
                            <?php echo ($_SESSION['is_logged'] ? $_SESSION['user_data']['currency'].number_format($data->recently_added[2]["price"] *
                                $_SESSION['user_data']['currency_rate'], 0, ".", " ") : '₦ '.number_format($data->recently_added[2]["price"], 0, ".", " "));
                            ?>
                        </p>
                    </div>
                    <div class="car_details_button">
                        <a href="<?php echo ($data->recently_added[2]['price'] ? '?p=adv_view&type=part&adv_id='.$data->recently_added[2]['adv_id'] : '#');?>">Details</a>
                    </div>
                </div>
            </li>
            <li>
                <div class="recently_added_holder1">
                    <a href=""><div class="image_fix_width1"><img src="<?php echo ($data->recently_added[3]['picture1'] ? $data->recently_added[3]['picture1'] : 'img/generic_car_part_placeholder.jpg');?>" alt=""></div>
                    <h3>
                        <?php
                        if(!empty($data->recently_added[3]['make'])) {
                            echo 'Car part for '.$data->recently_added[3]['make'].' '.$data->recently_added[3]['model'];
                        } else {
                            echo 'Car Part Ad #'.$data->recently_added[3]['adv_id'];
                        }
                        ?>
                    </h3>
                    </a>
                    <div class="price">
                        <p>
                            <?php echo ($_SESSION['is_logged'] ? $_SESSION['user_data']['currency'].number_format($data->recently_added[3]["price"] *
                                $_SESSION['user_data']['currency_rate'], 0, ".", " ") : '₦ '.number_format($data->recently_added[3]["price"], 0, ".", " "));
                            ?>
                        </p>
                    </div>
                    <div class="car_details_button">
                        <a href="<?php echo ($data->recently_added[3]['price'] ? '?p=adv_view&type=part&adv_id='.$data->recently_added[3]['adv_id'] : '#');?>">Details</a>
                    </div>
                </div>
            </li>
        </ul>
    </div>
</div>
<div id="most_viewed_holder">
    <h2>Most Viewed</h2>
    <div id="recently_added">
        <ul>
            <ul>
                <li>
                    <div class="recently_added_holder1">
                       <a href=""> <div class="image_fix_width1"><img src="<?php echo ($data->most_viewed[0]['picture1'] ? $data->most_viewed[0]['picture1'] : 'img/generic_car_part_placeholder.jpg');?>" alt=""></div>
                        <h3>
                            <?php
                            if(!empty($data->most_viewed[0]['year']) || !empty($data->most_viewed[0]['make'])) {
                                echo $data->most_viewed[0]['year'].' '.$data->most_viewed[0]['make'].' '.$data->most_viewed[0]['model'];
                            } else {
                                echo 'Generic Placeholder';
                            }
                            ?>
                        </h3>
                        </a>
                        <div class="price">
                            <p>
                                <?php echo ($_SESSION['is_logged'] ? $_SESSION['user_data']['currency'].number_format($data->most_viewed[0]["price"] *
                                    $_SESSION['user_data']['currency_rate'], 0, ".", " ") : '₦ '.number_format($data->most_viewed[0]["price"], 0, ".", " "));
                                ?>
                            </p>
                        </div>
                        <div class="car_details_button">
                            <a href="<?php echo ($data->most_viewed[0]['price'] ? '?p=adv_view&type=part&adv_id='.$data->most_viewed[0]['adv_id'] : '#');?>">Details</a>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="recently_added_holder1">
                        <a href=""><div class="image_fix_width1"><img src="<?php echo ($data->most_viewed[1]['picture1'] ? $data->most_viewed[1]['picture1'] : 'img/generic_car_part_placeholder.jpg');?>" alt=""></div>
                        <h3>
                            <?php
                            if(!empty($data->most_viewed[1]['year']) || !empty($data->most_viewed[1]['make'])) {
                                echo $data->most_viewed[1]['year'].' '.$data->most_viewed[1]['make'].' '.$data->most_viewed[1]['model'];
                            } else {
                                echo 'Generic Placeholder';
                            }
                            ?>
                        </h3>
                        </a>
                        <div class="price">
                            <p>
                                <?php echo ($_SESSION['is_logged'] ? $_SESSION['user_data']['currency'].number_format($data->most_viewed[1]["price"] *
                                    $_SESSION['user_data']['currency_rate'], 0, ".", " ") : '₦ '.number_format($data->most_viewed[1]["price"], 0, ".", " "));
                                ?>
                            </p>
                        </div>
                        <div class="car_details_button">
                            <a href="<?php echo ($data->most_viewed[1]['price'] ? '?p=adv_view&type=part&adv_id='.$data->most_viewed[1]['adv_id'] : '#');?>">Details</a>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="recently_added_holder1">
                        <a href=""><div class="image_fix_width1"><img src="<?php echo ($data->most_viewed[2]['picture1'] ? $data->most_viewed[2]['picture1'] : 'img/generic_car_part_placeholder.jpg');?>" alt=""></div>
                        <h3>
                            <?php
                            if(!empty($data->most_viewed[2]['year']) || !empty($data->most_viewed[2]['make'])) {
                                echo $data->most_viewed[2]['year'].' '.$data->most_viewed[2]['make'].' '.$data->most_viewed[2]['model'];
                            } else {
                                echo 'Generic Placeholder';
                            }
                            ?>
                        </h3>
                        </a>
                        <div class="price">
                            <p>
                                <?php echo ($_SESSION['is_logged'] ? $_SESSION['user_data']['currency'].number_format($data->most_viewed[2]["price"] *
                                    $_SESSION['user_data']['currency_rate'], 0, ".", " ") : '₦ '.number_format($data->most_viewed[2]["price"], 0, ".", " "));
                                ?>
                            </p>
                        </div>
                        <div class="car_details_button">
                            <a href="<?php echo ($data->most_viewed[2]['price'] ? '?p=adv_view&type=part&adv_id='.$data->most_viewed[2]['adv_id'] : '#');?>">Details</a>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="recently_added_holder1">
                       <a href=""><div class="image_fix_width1"> <img src="<?php echo ($data->most_viewed[3]['picture1'] ? $data->most_viewed[3]['picture1'] : 'img/generic_car_part_placeholder.jpg');?>" alt=""></div>
                        <h3>
                            <?php
                            if(!empty($data->most_viewed[3]['year']) || !empty($data->most_viewed[3]['make'])) {
                                echo $data->most_viewed[3]['year'].' '.$data->most_viewed[3]['make'].' '.$data->most_viewed[3]['model'];
                            } else {
                                echo 'Generic Placeholder';
                            }
                            ?>
                        </h3>
                        </a>
                        <div class="price">
                            <p>
                                <?php echo ($_SESSION['is_logged'] ? $_SESSION['user_data']['currency'].number_format($data->most_viewed[3]["price"] *
                                    $_SESSION['user_data']['currency_rate'], 0, ".", " ") : '₦ '.number_format($data->most_viewed[3]["price"], 0, ".", " "));
                                ?>
                            </p>
                        </div>
                        <div class="car_details_button">
                            <a href="<?php echo ($data->most_viewed[3]['price'] ? '?p=adv_view&type=part&adv_id='.$data->most_viewed[3]['adv_id'] : '#');?>">Details</a>
                        </div>
                    </div>
                </li>
            </ul>
        </ul>
    </div>
</div>
</div>

<script>
    //update model dynamically from database
    function get_model($make, $selected_model) {
        if ($make=="") {
            document.getElementById("model").innerHTML = "";
            return;
        }

        if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        }
        else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }

        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("model").innerHTML = xmlhttp.responseText;
            }
        };

        xmlhttp.open("GET","?p=get_models&make=" + $make + "&selected_model=" + $selected_model, true);
        xmlhttp.send();
    }

    <?php
     if(isset($data->model)) {
        echo "get_model('".urlencode($data->make)."', '".urlencode($data->model)."');";
     }
    ?>
</script>